import Vue from 'vue'

import Cookies from 'js-cookie'
import Print from 'vue-print-nb'//打印功能
import i18n from './lang' //国际化

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import axios from 'axios'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/jove.scss' // jove css
import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import * as $dataroomhttpaxios from '@/utils/dataroom-http.js'

import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { parseTime,formatDateC,resetForm,addDateRange,addMultipleDateRange,addMultipleDateRangeThree,selectDictLabel,selectDictLabels,handleTree } from "@/utils/jove";

import elDragDialog from '@/utils/el-drag-dialog' // 引入移动事件
Vue.directive('el-drag-dialog', elDragDialog);//添加标签事件绑定 可以放大移动弹窗
//弹窗默认点击遮罩改为不关闭 为了防止和拖拽冲突 ，这句需要放在use ElementUI之前（也可以不加这句，测试区别）
Element.Dialog.props.closeOnClickModal.default = false;

// 右击菜单组件
import Contextmenu from "vue-contextmenujs"
// 分页组件
import Pagination from "@/components/Pagination"
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
// 富文本组件
import Editor from "@/components/Editor"
import WangEditor from "@/components/WangEditor"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
//自定义组件-子表单
import TsSubFrom from '@/components/TsSubForm/'
//自定义组件-万能选择
import TsUniversalSelect from '@/components/TsSubForm/ts-universal-select.vue'
//自定义组件-待查询能力的数据表格index.vue
import CustomTable from '@/components/CustomTable/index.vue'
//自定义组件-el-table横向滚动条固定在窗口底部
import horizontalScroll from 'el-table-horizontal-scroll'
//大屏设计组件
import { registerConfig as registerConfigDataRoom, $dataRoomAxios } from '@gcpaas/data-room-ui'

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.formatDateC = formatDateC
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.addMultipleDateRange = addMultipleDateRange
Vue.prototype.addMultipleDateRangeThree = addMultipleDateRangeThree
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.$axios = axios
// 将大屏的aixos实例挂载到Vue上
Vue.prototype.$dataRoomAxios = $dataroomhttpaxios

// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('WangEditor', WangEditor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
Vue.component('tsSubForm', TsSubFrom)
Vue.component('tsUniversalSelect', TsUniversalSelect)
Vue.component('CustomTable', CustomTable)
Vue.use(horizontalScroll)

Vue.use(Print)
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
Vue.use(Contextmenu)
Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
})
DictData.install()
// 使用大屏提供的方法，进行后端服务地址注册
registerConfigDataRoom({
  routers: {
    // 大屏列表页面
    pageListUrl: '/big-screen-list',
    // 大屏设计页面
    designUrl: '/big-screen/design',
    // 大屏预览页面
    previewUrl: '/big-screen/preview',
    // 数据源管理页面
    dataSourceUrl: '/big-screen-dataSource',
    // 数据集管理页面
    dataSetUrl: '/big-screen-dataSet',
    // 资源库页面
    sourceUrl: '/big-screen-source',
    // 组件库页面
  	componentUrl: '/big-screen-components',
    //指定回退的路由
    pageManagementUrl:'/big-screen-list'
  },
  httpConfigs: {
    // 这里是大屏设计器对应的后端服务地址，可以为具体值，也可以在其他地方进行配置
		// 比如环境变量文件中，假设在 .env.development中配置了地址为：VUE_BIGSCREEN_BASE_URL='http://192.168.xx.xx:xxxx/xxx'
    baseURL: process.env.VUE_APP_BASE_API + '/dataroom',
    // 这里是大屏文件的访问前缀，一般和后端配置的gc.starter.file.urlPrefix保持一致即可
    //fileUrlPrefix: 'http://192.168.20.98:9000/server/static'
  },
  // 自定义title和logo等属性 
  starter: {
    title: '大屏设计器',
    logo: 'https://jovepcb.oss-cn-shenzhen.aliyuncs.com/jove-cloud/static/logo.png'
  }
// 此处第二个参数为自己项目中的路由实例对象
}, router)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false
Vue.config.silent = true //关闭浏览器vue warn

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
